﻿<catel:DataWindow x:Class="Catel.Examples.WPF.Memento.Views.PersonWindow"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:catel="http://catel.codeplex.com"
                  xmlns:Converters="clr-namespace:Catel.Examples.WPF.Memento.Converters"
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                  xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                  xmlns:Models="clr-namespace:Catel.Examples.Models;assembly=Catel.Examples.WPF.Models"
                  xmlns:ViewModels="clr-namespace:Catel.Examples.WPF.Memento.ViewModels"
                  d:DataContext="{d:DesignInstance ViewModels:DesignPersonViewModel,
                                                   IsDesignTimeCreatable=True}"
                  mc:Ignorable="d">

    <!--  Resources  -->
    <catel:DataWindow.Resources>
        <!--  Converters  -->
        <Converters:GenderToIsSelectedConverter x:Key="GenderToIsSelectedConverter" />
    </catel:DataWindow.Resources>

    <!--  Content  -->
    <catel:StackGrid>
        <!--  Row definitions  -->
        <catel:StackGrid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </catel:StackGrid.RowDefinitions>

        <!--  Column definitions  -->
        <catel:StackGrid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" MinWidth="300" />
        </catel:StackGrid.ColumnDefinitions>

        <!--  Gender  -->
        <Label Content="Gender" />
        <StackPanel x:Name="genderStackPanel" Orientation="Horizontal">
            <RadioButton Content="Male"
                         IsChecked="{Binding Gender,
                                             Converter={StaticResource GenderToIsSelectedConverter},
                                             ConverterParameter={x:Static Models:Gender.Male},
                                             ValidatesOnDataErrors=True,
                                             NotifyOnValidationError=True}"
                         Validation.ValidationAdornerSiteFor="{Binding ElementName=genderStackPanel}" />
            <RadioButton Content="Female"
                         IsChecked="{Binding Gender,
                                             Converter={StaticResource GenderToIsSelectedConverter},
                                             ConverterParameter={x:Static Models:Gender.Female},
                                             ValidatesOnDataErrors=True,
                                             NotifyOnValidationError=True}"
                         Validation.ValidationAdornerSiteFor="{Binding ElementName=genderStackPanel}" />
        </StackPanel>

        <!--  First name  -->
        <Label Content="First name" />
        <TextBox Text="{Binding FirstName, ValidatesOnDataErrors=True, NotifyOnValidationError=True}">
            <i:Interaction.Behaviors>
                <catel:UpdateBindingOnTextChanged UpdateDelay="100" />
            </i:Interaction.Behaviors>
        </TextBox>

        <!--  Middle name  -->
        <Label Content="Middle name" />
        <TextBox Text="{Binding MiddleName, ValidatesOnDataErrors=True, NotifyOnValidationError=True}">
            <i:Interaction.Behaviors>
                <catel:UpdateBindingOnTextChanged UpdateDelay="100" />
            </i:Interaction.Behaviors>
        </TextBox>

        <!--  Last name  -->
        <Label Content="Last name" />
        <TextBox Text="{Binding LastName, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />

        <!--  Custom error  -->
        <Label Content="Custom error" />
        <TextBox IsReadOnly="True" Text="{Binding CustomError, ValidatesOnDataErrors=True, NotifyOnValidationError=True}">
            <i:Interaction.Behaviors>
                <catel:UpdateBindingOnTextChanged UpdateDelay="100" />
            </i:Interaction.Behaviors>
        </TextBox>

        <!--  Custom error  -->
        <Label Content="Custom defined property" />
        <TextBox IsReadOnly="True" Text="{Binding CustomDefinedProperty, Mode=OneWay}" />

        <WrapPanel Grid.Row="6"
                   Width="118"
                   Margin="12,0,0,0">
            <!--  Added  -->
            <Button Command="{Binding Undo}"
                    Style="{DynamicResource ImageButtonStyle}"
                    ToolTip="Add">
                <Image Source="/Catel.Examples.WPF.Memento;component/Resources/Images/undo.png" />
            </Button>

            <!--  Edit  -->
            <Button Command="{Binding Redo}"
                    Style="{DynamicResource ImageButtonStyle}"
                    ToolTip="Edit">
                <Image Source="/Catel.Examples.WPF.Memento;component/Resources/Images/redo.png" />
            </Button>

            <!--  Remove  -->
        </WrapPanel>
    </catel:StackGrid>
</catel:DataWindow>
